package com.demo2do.fms.entity.supplier.common;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.demo2do.core.format.PersistentFormat;

/**
 * 服务供方审核记录表
 * 
 * @author Wy
 */
@Entity
@Table(name = "FMS_SUPPLIER_EVENT")
@PersistentFormat
public class SupplierEvent {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator")
    @SequenceGenerator(name = "generator", sequenceName = "HIBERNATE_SEQUENCE", allocationSize = 1)
    private Long id;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @PersistentFormat
    private Supplier supplier;
    
    /** 操作类型 */
    @Enumerated(EnumType.STRING)
    private SupplierEventType type;
    
    /** 驳回的理由 */
    @org.hibernate.annotations.Type(type="text")
    private String reason; 
    
    /** 创建人 */
    private Long creator;

    /** 创建时间 */
    private Date createTime;

    @Column(name = "IS_DISABLED")
    private Boolean disabled;
    
    /**
     * The default constructor
     */
    public SupplierEvent() {
    }
    
    /**
     * @param supplier
     * @param type
     * @param creator
     */
    public SupplierEvent(Supplier supplier, SupplierEventType type, Long creator) {
        this.supplier = supplier;
        this.type = type;
        this.creator = creator;
        this.createTime = new Date();
        this.disabled = false;
    }
    
    /**
     * 
     * @param reason
     * @return
     */
    public SupplierEvent editReason(String reason){
        this.reason = reason;
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the supplier
     */
    public Supplier getSupplier() {
        return supplier;
    }

    /**
     * @return the type
     */
    public SupplierEventType getType() {
        return type;
    }

    /**
     * @return the reason
     */
    public String getReason() {
        return reason;
    }

    /**
     * @return the creator
     */
    public Long getCreator() {
        return creator;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the disabled
     */
    public Boolean getDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param supplier the supplier to set
     */
    public void setSupplier(Supplier supplier) {
        this.supplier = supplier;
    }

    /**
     * @param type the type to set
     */
    public void setType(SupplierEventType type) {
        this.type = type;
    }

    /**
     * @param reason the reason to set
     */
    public void setReason(String reason) {
        this.reason = reason;
    }

    /**
     * @param creator the creator to set
     */
    public void setCreator(Long creator) {
        this.creator = creator;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(Boolean disabled) {
        this.disabled = disabled;
    }

}
